package com.right.dao.impl;

import java.util.List;

import com.Tools.DBTools;
import com.Tools.MD5Util;
import com.right.dao.AdminDao;
import com.right.entity.Admin;
import com.right.entity.Users;

public class AdminDaoImpl implements AdminDao {
   
	/**
	 * 登入
	 */
	@Override
	public boolean login(String adminname, String adminpwd) {
		String sql = "select adminid from admin where adminname=? and adminpwd=?";
		 
		List<Admin> list = (List<Admin>) DBTools.exQuery(sql, Admin.class,adminname,adminpwd );
		if (list.size() != 0) {
			return true;
		}
		return false;
	}

	@Override
	public Admin getIdByName(String adminname) {
		String sql ="select adminid from admin where adminname = ?";
		List<Admin> list = (List<Admin>) DBTools.exQuery(sql, Admin.class, adminname);
		if (list.size() == 0) {
			return null;
		}
		return list.get(0);
	}

	@Override
	public Admin getAdminByid(int adminid) {
		String sql = "select * from admin where adminid = ?";
		List<Admin> list = (List<Admin>) DBTools.exQuery(sql, Admin.class,adminid);
		if (list.size() == 0) {
			return null;
		}
		return list.get(0);
	}
 	

}
